<?php

require "funciton.php";

$code = $_GET['code'];
$state = $_GET['state'];
$base_uri = $_GET['base_uri'];

//获取userinfo
//$userinfo_json = wxoauth2_request_userinfo_proxy($code);

//获取open
$userinfo_json = wxoauth2_request_openid($code);
$userinfo = json_decode($userinfo_json , true);

//保存用户信息到session中
if(!isset($_SESSION)){
	session_start();
}
$_SESSION['oauth2_userinfo'] = $userinfo;

//print_r($userinfo);
header("location: $base_uri");
exit;